﻿using AutomatedTestDataManagement.Models;
using System.Data;
using System.Linq;
using System.Web.Mvc;

namespace AutomatedTestDataManagement.Controllers
{
    public class MetaTableController : Controller
    {
        private ApplicationTestDataEntities db = new ApplicationTestDataEntities();

        //
        // GET: /MetaTable/

        public ActionResult Index()
        {
            return View(db.ViewMetaTables.ToList());
        }

        //
        // GET: /MetaTable/Details/5

        public ActionResult Details(string id = null)
        {
            ViewMetaTable viewmetatable = db.ViewMetaTables.Find(id);
            if (viewmetatable == null)
            {
                return HttpNotFound();
            }
            return View(viewmetatable);
        }

        //
        // GET: /MetaTable/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /MetaTable/Create

        [HttpPost]
        public ActionResult Create(ViewMetaTable viewmetatable)
        {
            if (ModelState.IsValid)
            {
                db.ViewMetaTables.Add(viewmetatable);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(viewmetatable);
        }

        //
        // GET: /MetaTable/Edit/5

        public ActionResult Edit(string id = null)
        {
            ViewMetaTable viewmetatable = db.ViewMetaTables.Find(id);
            if (viewmetatable == null)
            {
                return HttpNotFound();
            }
            return View(viewmetatable);
        }

        //
        // POST: /MetaTable/Edit/5

        [HttpPost]
        public ActionResult Edit(ViewMetaTable viewmetatable)
        {
            if (ModelState.IsValid)
            {
                db.Entry(viewmetatable).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(viewmetatable);
        }

        //
        // GET: /MetaTable/Delete/5

        public ActionResult Delete(string id = null)
        {
            ViewMetaTable viewmetatable = db.ViewMetaTables.Find(id);
            if (viewmetatable == null)
            {
                return HttpNotFound();
            }
            return View(viewmetatable);
        }

        //
        // POST: /MetaTable/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(string id)
        {
            ViewMetaTable viewmetatable = db.ViewMetaTables.Find(id);
            db.ViewMetaTables.Remove(viewmetatable);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }

    }
}